<template>
	<view class="order">
		<view class="tabs">
			<view v-for="(item,index) in tabsList" :key="index" class="tabItem" @click="changeTabs(index)" :style="{borderBottom: TabsCurrent == index?'#73F0EA 8rpx solid':''}">
				<view class="size"
					:style="{color:TabsCurrent == index ?'#73F0EA':'#999999',fontWeight:TabsCurrent == index ?'800':'400'}">
					{{item.name}}
				</view>				
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll_box" @scrolltolower="scrolltolower">
			<view class="comlum_box" v-if="orderList.length">
				<view v-for="(item,index) in orderList" :key="index" 
					class="Item" 
					:style="{ animationDelay: index * 0.1 + 's' }"
					@click="$ROUTELINK('deatil?order_no=' + item.order_no)">
					<view class="header">
						<view class="left">
							<image :src="item.category_image" mode="aspectFill" class="logo" v-if="item.category_image"></image>
							<view class="name">
								{{item.shop_name}}
							</view>
						</view>
						<view class="right">
							<view class="size1">
								{{item.pay_str}}
							</view>
							<u-icon name="arrow-right" color="#999999" size="14"></u-icon>
						</view>
					</view>
					<view class="time">
						{{item.time}}
					</view>
					<view class="bottom">
						<image :src="item.image" mode="" class="imgs"></image>
						<view class="b_right">
							<view class="top1">
								<view class="size2">
									{{item.title}}
								</view>
								<view class="right3">
									<text class="size3">￥</text>
									<text class="size4">{{item.pay_cost}}</text>
								</view>
							</view>
							<view class="top2">
								<view class="left2">
									{{item.form_str}}
								</view>
								<view class="right2">
									{{item.num_str}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="TabsCurrent == 0?'订单':TabsCurrent == 1?'会员卡订单':'课程订单'"></empty>
		</scroll-view>
	</view>
</template>

<script>
	import empty from '../components/empty.vue'
	import{
		orderList
	} from '@/api/user.js'
	export default{
		components:{
			empty
		},
		data(){
			return{
				status: 'loadmore', //当前状态
				// 导航
				tabsList:[
					{
						name:'全部'
					},
					{
						name:'会员卡'
					},
					{
						name:'课程'
					}
				],
				TabsCurrent:0,
				query:{
					form:'all',
					page:1
				},
				orderList:[]
			}
		},
		onLoad() {
			this.getOrder()
		},
		methods:{
			scrolltolower(){
				this.query.page ++
				this.getOrder()
			},
			changeTabs(index){
				if(this.TabsCurrent != index){
					if(!index){
						this.query.form = 'all'
					}else if(index == 1){
						this.query.form = 'card'
					}else{
						this.query.form = 'course'
					}
					this.status = 'more'
					this.TabsCurrent = index
					this.query.page = 1
					this.orderList = []
					this.getOrder()
				}
				
			},
			getOrder(){
				orderList(this.query).then(({data:res})=>{
					if(res.code == 1){
						const list = []
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.orderList = this.orderList.concat(res.data.list)
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #e9e9e9;
		// 全局关闭点击高亮效果
		-webkit-tap-highlight-color: transparent;
		tap-highlight-color: transparent;
	}
	
	// 全局关闭所有可点击元素的高亮效果
	* {
		-webkit-tap-highlight-color: transparent;
		tap-highlight-color: transparent;
		outline: none;
		-webkit-touch-callout: none;
	}
	.order{
		display: flex;
		flex-direction: column;
		align-items: center;
		.tabs {
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-around;
			background-color: #ffffff;
			padding-top: 33rpx;
		
			.tabItem {
				display: flex;
				flex-direction: column;
				align-items: center;
				height: 60rpx;
				transition: all 0.3s ease;
				cursor: pointer;
				// 关闭点击高亮效果
				-webkit-tap-highlight-color: transparent;
				tap-highlight-color: transparent;
				outline: none;
				-webkit-touch-callout: none;
				-webkit-user-select: none;
				user-select: none;
				.size{
					font-size: 28rpx;
					letter-spacing: 0.62rpx;
					font-family: PingFang SC, PingFang SC-Heavy;
					transition: all 0.3s ease;
				}
				.sliding-block-box{
					height: 20rpx;
					padding-top: 12rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
				}
				.sliding-block-child {
					width: 44rpx;
					height: 8rpx;
					background: #73F0EA;
					border: 2rpx solid rgba(0, 0, 0, 0.00);
					border-radius: 2rpx;
				}
			}	
		}
		.scroll_box {
			height: 90vh;
			width: 100%;
			padding-top: 20rpx;
			.comlum_box {
				width: 100%;
				padding: 0 24rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				.Item{
					width: 702rpx;
					height: 276rpx;
					background: #ffffff;
					border-radius: 16rpx;
					padding: 26rpx 24rpx;
					display: flex;
					flex-direction: column;
					margin-bottom: 24rpx;
					// 动画效果
					opacity: 0;
					transform: translateY(30rpx);
					animation: fadeInUp 0.6s ease forwards;
					transition: transform 0.3s ease;
					// 关闭点击高亮效果
					-webkit-tap-highlight-color: transparent;
					tap-highlight-color: transparent;
					outline: none;
					-webkit-touch-callout: none;
					-webkit-user-select: none;
					user-select: none;
					.header{
						width: 100%;
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 12rpx;
						.left{
							flex: 1;
							display: flex;
							flex-direction: row;
							align-items: center;
							.logo{
								width: 114rpx;
								height: 36rpx;
								margin-right: 12rpx;
							}
						}
						.right{
							display: flex;
							flex-direction: row;
							align-items: center;
							.size1{
								margin-right: 7rpx;
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Medium;
								font-weight: 500;
								text-align: left;
								color: #999999;
							}
						}
					}
					.time{
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #999999;
						margin-bottom: 24rpx;
					}
					.bottom{
						display: flex;
						flex-direction: row;
						.imgs{
							width: 160rpx;
							height: 120rpx;
							margin-right: 20rpx;
						}
						.b_right{
							display: flex;
							flex-direction: column;
							flex: 1;
							.top1{
								display: flex;
								flex-direction: row;
								align-items: center;
								width: 100%;
								.size2{
									font-size: 32rpx;
									font-family: PingFang SC, PingFang SC-Bold;
									font-weight: 700;
									text-align: left;
									color: #333333;
									flex: 1;
								}
								.right3{
									display: flex;
									flex-direction: row;
									align-items: baseline;
									.size3{
										font-size: 24rpx;
										font-family: PingFang SC, PingFang SC-Bold;
										font-weight: 700;
										color: #f37364;
									}
									.size4{
										font-size: 32rpx;
										font-family: DIN, DIN-Bold;
										font-weight: 700;
										color: #f37364;
									}
								}
							}
							.top2{
								display: flex;
								flex-direction: row;
								align-items: center;
								width: 100%;
								.left2{
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Medium;
									font-weight: 500;
									color: #999999;
									flex: 1;
								}
								.right2{
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Regular;
									font-weight: 400;
									color: #666666;
								}
							}
						}
					}
				}
			}	
		}	
	}
	
	// 动画关键帧
	@keyframes fadeInUp {
		0% {
			opacity: 0;
			transform: translateY(30rpx);
		}
		100% {
			opacity: 1;
			transform: translateY(0);
		}
	}
</style>